import java.util.*;

class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        // code here
        String str = sc.next();

        //取出前导零
        int index = 0;
        while (str.charAt(index) == '0') {
            index++;
        }

        String n = str.substring(index);

        while (true) {
            if (!n.substring(0, 1).equals(n.substring(n.length() - 1))) {
                n = sub(n);
                continue;
            }
            if (method(n)) {
                System.out.println(n);
                break;
            }
            n = sub(n);
        }

        sc.close();
    }

    //判断是否为回文数
    public static boolean method(String num) {
        char[] ch = num.toCharArray();
        int len = ch.length;
        for (int i = 0, j = len - 1; i < j; i++, j--) {
            if (ch[i] != ch[j]) {
                return false;
            }
        }

        return true;
    }

    //将 str 减一
    public static String sub(String str) {
        int len = str.length();
        char[] ch = str.toCharArray();
        char n = ch[len - 1]; //取出最后一个数字
        if (n != '0') {
            str = str.substring(0, len - 1) + --n;
        } else {
            //向前借一位
            for (int i = len - 1; i >= 0; i--) {
                if (ch[i] == '0') {
                    ch[i] = '9';
                } else {
                    // String temp = new String(Integer.parseInt(ch[i]) - 1);
                    ch[i]--;
                    break;
                }
            }
            str = new String(ch);
            //去除前导零
            int index = 0;
            while (str.charAt(index) == '0') {
                index++;
            }
            str = str.substring(index);
        }

        return str;
    }
}